<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>委外入库管理</title>
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/outsidein";
		var basic_WUrl="logic/outsidein";
		var basic_Title="委外入库管理";
		var show_Width=950;
		var show_Hight=400;
		var user='${user.name}';
		var zdType = '${zdType }';
		function createSearch(){
			init(1,8,'100,100,100,100,100,100,100,100','25%');
			//第一行的数据
			addCommon(0,0,"lable","委外入库单号");
			addCommon(0,1,"txtlike","zd001Code");
			addCommon(0,2,"lable","入库仓库：");
			addCommon(0,3,"selectEnum","zd003WhCode","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd002Code}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,4,"lable","制单人");
			addCommon(0,5,"txtlike","zd005Aegnt");
			addCommon(0,6,"lable","单据状态：");
			addCommon(0,7,"selectEnum","zd001Status","<option></option><option value='OUTSIDEIN_SAVE'>草稿</option>"+
					"<option value='OUTSIDEIN_SUBMIT'>审批中</option><option value='OUTSIDEIN_END'>完成</option><option value='OUTSIDEIN_BACK'>驳回</option>");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do?zdType="+zdType);
		}
		//新增
		function addOutSdIn(){
			var url = basic_WUrl+"/operate/add/0.do?zdType="+zdType;
			ShowIframeDialog("operate",basic_Title,url,show_Width,show_Hight);
		} 
		$(function(){
			var zdType = '${zdType}';
			var grid = $("#table1").ligerGrid({
		        columns: [
		                  { display: '入库单号', name: 'zd001Code', width: 200},
		                  { display: '入库仓库', name: 'zd003WhName', width: 200},
		                  { display: '单据状态', name: 'zd001Status', width: 200,
		                	render : function(item){
		                		if (item.zd001Status == 'OUTSIDEIN_SAVE')
		                			return "草稿";
		                		if (item.zd001Status == 'OUTSIDEIN_SUBMIT')
		                			return "审批中";
		                		if (item.zd001Status == 'OUTSIDEIN_END')
		                			return "完成";
		                		if (item.zd001Status == 'OUTSIDEIN_BACK')
		                			return "退回";
		                	}  
		                  },
		                  { display: '出库状态', name: 'zd002OutStatus', width: 200,
			                	render : function(item){
			                		if (item.zd002OutStatus == 'OUTSIDEIN_WHNO'){
			                			return "未出库";
			                		}else if(item.zd002OutStatus == 'OUTSIDEIN_WHST'){
			                			return "部分出库";
			                		}else if(item.zd002OutStatus == 'OUTSIDEIN_WHCP'){
			                			return "完全出库";
			                		}else{
			                			return "未出库";
			                		}
			                	}  
			                  },
		                  { display: '入库时间', name: 'zd006Date', width: 200,
		                	  render: function (item){
		                		  var cdate=new Date(item.zd006Date);
		                		  return formatDate(cdate,"yyyy-MM-dd");
		                	  }
		                  },
		                  { display: 'PI单号', name: 'zd009PiCode', width: 200},
		                  { display: '制单人', name: 'zd005Aegnt',width: 200 }
		                  ],  usePager: true,pageSize:15,
		                      url : basic_Url+"/list.do?zdType="+zdType,
		                      width: '100%', height: '98%',pageSizeOptions :[15,25,35], checkbox: true,rownumbers:true,
		                      onDblClickRow : function (data, rowindex, rowobj){
		                          edit(data);
		                       }
		                  });
			$("#pageloading").hide();
		});
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			var bol = false;
			if (rows==null){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}else{
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName !='${user.name}'){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('只能对本人建的单据进行删除操作!');
					return;
				}else{
					bol = false;
					for(var i=0;i<rows.length;i++){
					 	if (rows[i].zd001Status == 'OUTSIDEIN_SAVE'|| rows[i].zd001Status == 'OUTSIDEIN_BACK'){
					 		bol = true;
						}
					}
					if(bol){
						del();
						bol = false;
					}else{
						$.dialog.alert('草稿状态的单据才能进行删除!');
						return;
					}
				}
			}
			
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
	</script>
  </head>
<body onload="createSearch()">
	<div id="layout1">
    	<div position="top">
        	<div class="panelBar">
	        	<ul class="toolBar">
		        	<li><a class="add" onclick="addOutSdIn();"><span>添加</span></a></li>
				    <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
                </ul>
          	</div>
          	<div id="pageHeader" class="pageHeader">
            	<div class="searchBar" id="multipleSearchDialog">
	            	<table class="table" width="100%" id="searchHeader" >  
                    	<tbody id="newbody"></tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               	</div>
          	</div>
      	</div>
      	<div position="center" id="table1"></div>
      	<div class="clear"></div>
   </div>
</body>
</html>